Skip to content

Compose: expose painterResource in Xamarin.AndroidX.Compose.UI.Android#1449

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-painterresource-binding-issue
Closed

Compose: expose painterResource in Xamarin.AndroidX.Compose.UI.Android#1449
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-painterresource-binding-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

The shipped Xamarin.AndroidX.Compose.UI.Android 1.11.2 assembly does not contain painterResource, so painterResource(@DrawableRes Int): Painter was unreachable from C# — leaving the bound Painter/BitmapPainter/ColorPainter types unusable in typical Compose code.

The current binder toolchain already projects this method automatically; the checked-in binding predates that. No metadata transform is needed (an add-node for it would produce a duplicate method, CS0111). The fix is to record the regenerated API and ship a new package revision.

Changes

  • PublicAPI/PublicAPI.Unshipped.txt: regenerated from a real local build of ui-android rather than hand-edited. This file is auto-generated at build time (Directory.Build.targets_GeneratePublicApiFiles), so a manual single-line edit had no effect. The regenerated file is a strict superset (+403 lines, 0 removals) and includes PainterResources_androidKt.PainterResource(int, IComposer?, int) -> Painter.
  • config.json: bump Xamarin.AndroidX.Compose.UI.Android 1.11.21.11.2.1 to trigger a rebuild that ships the bound method.

The bound method projects as:

public static Painter PainterResource (int id, IComposer? _composer, int _changed);

Notes

  • AndroidX.Compose.UI.Res already exists in published-namespaces.txt; no namespace-file change required.
  • Verified empirically: the shipped 1.11.2 dll lacks painterResource, while a clean local build with the current toolchain emits it automatically (no BG8605 drop).
  • Rebuilding under the current toolchain also surfaces ~96 inline-class mangled methods ([generator] Phase 2: Kotlin @JvmInline value class projection java-interop#1440) that weren't in shipped 1.11.2. These are now reflected in the regenerated API file since they will ship with 1.11.2.1; the repo already ships similar entries in ui-unit-android/ui-graphics-android. They can be stripped via metadata instead if preferred.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix painterResource not bound in Xamarin.AndroidX.Compose.UI.Android Compose: expose painterResource in Xamarin.AndroidX.Compose.UI.Android Jun 5, 2026
Copilot AI requested a review from jonathanpeppers June 5, 2026 23:12
@jonathanpeppers
Copy link
Copy Markdown
Member

@copilot this PR does nothing?!?

… painterResource + toolchain-surfaced API)

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 6, 2026

@copilot this PR does nothing?!?

You're right that the earlier diff was effectively a no-op. I dug in and verified the actual situation:

  • The shipped Xamarin.AndroidX.Compose.UI.Android 1.11.2 assembly does not contain painterResource (confirmed against the dll from nuget.org).
  • A clean local build of ui-android with the current toolchain does emit it automatically — public static Painter PainterResource(int id, IComposer? _composer, int _changed) — with no metadata transform required.
  • The earlier change hand-edited PublicAPI/PublicAPI.Unshipped.txt, but that file is auto-generated after build (Directory.Build.targets_GeneratePublicApiFiles), so a single hand-written line is meaningless and gets overwritten.

What I changed:

  • Replaced the hand-edit with the actually build-regenerated PublicAPI.Unshipped.txt (+403 lines, strict superset, 0 removals), which now truthfully includes PainterResource.
  • Kept config.json 1.11.21.11.2.1 to ship the rebuild.

One thing worth a decision: rebuilding with the current toolchain also surfaces ~96 inline-class mangled methods (e.g. ..._u2d..., Rectangle___Goahg) that weren't in shipped 1.11.2 (dotnet/java-interop#1440). They're now reflected in the regenerated API file since they will ship with 1.11.2.1. The repo already ships similar mangled entries in ui-unit-android/ui-graphics-android, so this is consistent, but let me know if you'd prefer to strip them via metadata instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compose: painterResource(Int, Composer) not bound in Xamarin.AndroidX.Compose.UI.Android (PainterResources_androidKt wrapper is empty)

2 participants